home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir31 / bbsamt40.zip / BANSI.DOC next >
Text File  |  1994-04-07  |  20KB  |  543 lines

  1. Paul Wheaton of Banana Programming has done a thorough study of the
  2. conflicts between the ANSI standard and ANSI music codes.  Bloomunit
  3. wishes to strongly endorse the changes he suggests in the below
  4. BANSI.DOC, and to encourage all software authors and developers to
  5. make the suggested modifications to their ANSI music-supporting communi-
  6. cations programs by January 1, 1997.
  7.  
  8. The most notable of these suggestions is replacing the M sequence for
  9. starting ANSI music with the N sequence, which has no conflicts at all
  10. with the existing standard, and furthermore is easy to remember since it
  11. relates to the  character (Ctrl N) which closes a music string.
  12.  
  13. With cooperation and united effort, those of us who use and support BBS
  14. ANSI music can bring about a permanent change for the better, and make
  15. it more accessible for all to enjoy.
  16.  
  17. Linda Bloom
  18. Bloomunit BBS
  19. April 6, 1994
  20.  
  21. --------------------------------------------------------
  22.  
  23. BANSI.DOC
  24. copyright (c) 1994 by Paul Wheaton, Banana Programming
  25.  
  26. The ANSI-BBS industry is riddled with conflicts.  Since the true ANSI
  27. standard has not been strictly followed, a variety of variations have
  28. evolved.  Some have become popular.
  29.  
  30. This document spells out what BananaCom uses for it's terminal emulation: A
  31. mish-mash of ANSI, VT100, pseudo-ANSI and pseudo-VT100 that tries to follow
  32. what most modem services expect and use. Perhaps this will help to make
  33. BBS's and COM programs work together with a little less research and
  34. programming effort.
  35.  
  36. Terminal sends:
  37.  
  38.   All ASCII characters from 1 to 127 are sent as is.  If somebody wants to
  39.   feed a special character that comes through as a character 128 through
  40.   255, send that through too.
  41.  
  42.   ANSI terminal emulation is supposed to be a superset of the escape
  43.   sequences used by the DEC VT100 terminal.  These required that an escape
  44.   (ASCII 27) be sent followed by some other characters.  The following
  45.   keystrokes are well established:
  46.  
  47.         Keystroke             Sent
  48.  
  49.         left arrow key        ESC [ D
  50.         right arrow key       ESC [ C
  51.         up arrow key          ESC [ A
  52.         down arrow key        ESC [ B
  53.         home key              ESC [ H
  54.         end key               ESC [ K
  55.         ^home key             ESC [ L
  56.         ^page up              ESC [ M
  57.  
  58.         F1 key                ESC O P
  59.         F2 key                ESC O Q
  60.         F3 key                ESC O w
  61.         F4 key                ESC O x
  62.  
  63.                                   ^capital "oh", not a zero
  64.  
  65.   All other keys send a zero and then the BIOS scan code.  Note that most
  66.   com programs will use Alt-A through Alt-Z and Alt-1 through Alt-9 and
  67.   Alt-0.  If there happens to be keys left they will be passed through.
  68.  
  69.   Function keys are your best bet and are all passed through
  70.  
  71.               Alone     Shift      Ctrl      Alt
  72.  
  73.         F1              0  84     0  94     0 104
  74.         F2              0  85     0  95     0 105
  75.         F3              0  86     0  96     0 106
  76.         F4              0  87     0  97     0 107
  77.         F5    0  59     0  88     0  98     0 108
  78.         F6    0  60     0  89     0  99     0 109
  79.         F7    0  61     0  90     0 100     0 110
  80.         F8    0  62     0  91     0 101     0 111
  81.         F9    0  63     0  92     0 102     0 112
  82.         F10   0  64     0  93     0 103     0 113
  83.  
  84.    Some com programs use the Page Up and Page Down keys to initiate a file
  85.    transfer although this seems to be changing - these keys are of great
  86.    use to BBS's.
  87.  
  88.         Page Up           0  73
  89.         Page Down         0  81
  90.         Insert            0  82
  91.  
  92.    Note that when you press control-page-down with some terminal programs,
  93.    they send   ESC [ H ESC [ 2 J   and a lot of BBS's simply ignore that.
  94.  
  95.         ctrl-page-down    0 118
  96.         ctrl-end          0 117
  97.         ctrl-left-arrow   0 115
  98.         ctrl-right-arrow  0 116
  99.         shift-tab         0 15
  100.  
  101. Terminal receives:
  102.  
  103.   Most ANSI terminals use a screen 80x24 - with the last line reserved for
  104.   reporting the current status of the terminal program.  BananaCom uses
  105.   this standard.
  106.  
  107.   There are a few ASCII characters that have a special effect on on the
  108.   terminal:
  109.  
  110.       Dec  Hex  char   function
  111.  
  112.        7    7    ^G    beep
  113.        8    8    ^H    destructive backspace
  114.        9    9    ^I    tab - move to next tab column (8,16,24,32,40...)
  115.       10    A    ^J    line feed - move down one. Scroll up if needed
  116.       12    C    ^L    clear screen (normal attribute) & home cursor (1,1)
  117.       13    D    ^M    return - move cursor to column 1
  118.  
  119.  
  120.   Escape sequences do not have spaces in them.  Spaces have been added
  121.   here for readability.
  122.  
  123.   Anything appearing in angle brackets is a numeric variable.  The angle
  124.   brackets are not sent.
  125.  
  126.   ESC D    scroll up
  127.  
  128.     All of the text on the screen (or the scrolling region, if one is
  129.     defined) is scrolled up one line.  The bottom line is filled with
  130.     spaces colored according to the current attribute.
  131.  
  132.     Note that there is no left bracket "[" between the ESC and the 'D'.
  133.  
  134.     Example:  ESC D              scroll all text up one line
  135.  
  136.   ESC M    scroll down
  137.  
  138.     All of the text on the screen (or the scrolling region, if one is
  139.     defined) is scrolled down one line.  The top line is filled with spaces
  140.     colored according to the current attribute.
  141.  
  142.     Note that there is no left bracket "[" between the ESC and the 'M'.
  143.  
  144.     Example:  ESC M              scroll all text down one line
  145.  
  146.   ESC [ @    insert char
  147.  
  148.     Insert a space into the current line at the current cursor position.
  149.     The character at column 80 is thrown out.  The current attribute is
  150.     used for the new space.
  151.  
  152.   ESC [ <NumLines> A    cursor up
  153.  
  154.     Move the cursor up specified number of lines (default is one).
  155.  
  156.     If "ESC [ ? 6 h" has been received since last "ESC [ <var> ; <var> r"
  157.     then the cursor will not be allowed to move beyond the top of the
  158.     scrolling region.
  159.  
  160.     Example:  ESC [ 1 0 A        move up ten lines
  161.  
  162.     Example:  ESC [ A            move up one line
  163.  
  164.   ESC [ <NumLines> B    cursor down
  165.  
  166.     Move the cursor down specified number of lines (default is one).
  167.  
  168.     If "ESC [ ? 6 h" has been received since last "ESC [ <var> ; <var> r"
  169.     then the cursor will not be allowed to move beyond the bottom of the
  170.     scrolling region.
  171.  
  172.     Example:  ESC [ 1 0 B        move down ten lines
  173.  
  174.     Example:  ESC [ B            move down one line
  175.  
  176.   ESC [ <NumCols> C    cursor right
  177.  
  178.     Move the cursor right specified number of lines (default is one).
  179.  
  180.     Example:  ESC [ 1 0 C        move right ten columns
  181.  
  182.     Example:  ESC [ C            move right one column
  183.  
  184.   ESC [ <NumCols> D    cursor left
  185.  
  186.     Move the cursor left specified number of lines (default is one).  Cannot
  187.     move beyond left of screen.
  188.  
  189.     Example:  ESC [ 1 0 D        move left ten columns
  190.  
  191.     Example:  ESC [ D            move left one column
  192.  
  193.   ESC [ <Num> E    line feed
  194.  
  195.     Convert to specified number of line feeds.  If the cursor is at the
  196.     bottom of the screen (or scrolling region if one is defined) text will
  197.     be scrolled up and the bottom line will be cleared.
  198.  
  199.     Example:  ESC [ 1 0 E        convert and process as ten linefeeds
  200.  
  201.     Example:  ESC [ E            convert and process as onr linefeed
  202.                                  (why not just send ^J ?)
  203.  
  204.   ESC [ F    undefined
  205.   ESC [ G    undefined
  206.  
  207.   ESC [ <row> ; <col> H    move to
  208.  
  209.     Move cursor to this position.
  210.  
  211.     If "ESC [ ? 6 h" has been received since the last
  212.     "ESC [ <var> ; <var> r" then the cursor will be positioned relative to
  213.     the scrolling region.
  214.  
  215.     This will perform exactly the same as "ESC [ <row> ; <col> f".
  216.  
  217.     Example:  ESC [ 1 0 ; 5 H    The cursor will be positioned at row 10
  218.                                  and column 5.
  219.  
  220.     Example:  ESC [ 10 H         The cursor will be positioned at row 10
  221.                                  and column 1.
  222.  
  223.     Example:  ESC [ H            The cursor will be positioned at row 1
  224.                                  and column 1.
  225.  
  226.   ESC [ I    undefined
  227.  
  228.   ESC [ <type> J    clear all or part of display
  229.  
  230.     Clear all or part of the screen (or scrolling region if one is
  231.     defined).
  232.  
  233.     The cleared region will always be the "normal attribute" although
  234.     future text will use the last set attribute.
  235.  
  236.     Cursor does not move.
  237.  
  238.     Example:  ESC [ 0 J          Clear from cursor to end of screen
  239.  
  240.     Example:  ESC [ 1 J          Clear from beginning of screen to cursor
  241.  
  242.     Example:  ESC [ 2 J          Clear whole screen
  243.                                  (note that sending ^L does the same thing)
  244.  
  245.     Example:  ESC [ J            same as "ESC [ 0 J"
  246.  
  247.   ESC [ <type> K    clear all or part of current line
  248.  
  249.     The cleared region will always be the "normal attribute" although
  250.     future text will use the last set attribute.
  251.  
  252.     Cursor does not move.
  253.  
  254.     Example:  ESC [ 0 K          Clear from cursor to end of line
  255.  
  256.     Example:  ESC [ 1 K          Clear from beginning of line to cursor
  257.  
  258.     Example:  ESC [ 2 K          Clear whole line
  259.  
  260.     Example:  ESC [ K            same as "ESC [ 0 K"
  261.  
  262.   ESC [ <num> L    insert line
  263.  
  264.     "<num>" blank lines will be inserted at the current cursor location.
  265.     These lines will have the color of the current attribute.  The previous
  266.     current line and all of the lines below will be moved down.  Lines that
  267.     are scrolled beyone the bottom of the screen (or scrolling region, if
  268.     one is defined) will be lost.
  269.  
  270.     Example:  ESC [ 1 0 K        insert ten lines
  271.  
  272.     Example:  ESC [ K            insert one line
  273.  
  274.   ESC [ M    ANSI Music / delete line
  275.  
  276.     This is the biggest conflict in ANSI emulation.  The actual ANSI
  277.     standard clearly states that this sequence is to be used for "delete
  278.     line".  The person that came up with "ANSI music" must not have known
  279.     this.  There are still many modem services and mainframe computers that
  280.     depend on this being "delete line" - however, far more people are
  281.     served by systems that depend on this being "ANSI music".
  282.  
  283.     What this means is that as a programmer, you cannot depend on ESC [ M.
  284.     Some modem service and com programs will lock up when they expect one
  285.     thing and receive another.
  286.  
  287.     Here is a solution:
  288.  
  289.         a)  A modem service can send "ESC [ b" to the terminal.  If the
  290.         emulation outlined in this document is supported, 000 will be sent
  291.         back.  If it is not, the terminal will most likely not show the
  292.         escape sequence and you can then know that ESC [ M should be
  293.         avoided since its interpretation is unknown and could cause a
  294.         lockup.
  295.  
  296.         b)  Use "ESC [ N" for music and "ESC [ Y" for delete line.
  297.  
  298.     What BananaCom supports for ESC [ M may change although at the time of
  299.     this writing, it is used for ANSI music.  See "ESC [ N" and "ESC [ Y"
  300.     for information on how to use ANSI music and delete line.
  301.  
  302.   ESC [ N <music codes> <^N>  ANSI music (formerly unused)
  303.  
  304.     This command is provided with BananaCom as a substitute to the
  305.     traditional ANSI music sequence of "ESC [ M" since that sequence has
  306.     conflicts.
  307.  
  308.     For complete information on how to use ANSI music, look for the file
  309.     BBSAMT*.* (BBS ANSI Music Tutor) by Linda Bloom.  This file is
  310.     available on the Montana Banana BBS (406)543-8234 and Bloomunit BBS
  311.     (407)687-8712.
  312.  
  313.     Example:  ESC [ N E 8 G 8 G 8 G 8 F 4 E 8 G 2 ^N    this will belt out
  314.     the first few notes of "Popeye the Sailor".  "ESC [ N" starts the music
  315.     sequence and the control-N character finishes.  What's in between are
  316.     all of the notes and how long each note lasts.  Further details of the
  317.     music may be provided as specified in BBSAMT.
  318.  
  319.     Note that this is not an ANSI standard, but something that is in
  320.     BananaCom.  Other COM program folks are welcome to do the same.
  321.  
  322.   ESC [ O    undefined
  323.  
  324.   ESC [ <num> P    delete char
  325.  
  326.     Delete the character at the current cursor position.  All characters to
  327.     the right of the cursor will be shifted one to the left.  The right
  328.     most character on the screen will be converted to a space and will have
  329.     the same attribute as the character that used to be there.
  330.  
  331.     Example:  ESC [ 1 0 P        delete ten characters
  332.  
  333.     Example:  ESC [ P            delete one character
  334.  
  335.   ESC [ Q    undefined
  336.   ESC [ R    undefined
  337.  
  338.   ESC [ S    scroll up
  339.  
  340.     see ESC D
  341.  
  342.   ESC [ T    scroll down
  343.  
  344.     see ESC M
  345.  
  346.   ESC [ U    clear
  347.  
  348.     Clear the screen with the "normal" attribute and home the cursor.
  349.     New text will use the previously defined attribute.
  350.  
  351.   ESC [ V    undefined
  352.   ESC [ W    undefined
  353.   ESC [ X    undefined
  354.  
  355.   ESC [ <num> Y    delete line
  356.  
  357.     This command is provided with BananaCom as a substitute to the
  358.     traditional delete line sequence of "ESC [ M" since that sequence has
  359.     conflicts.
  360.  
  361.     "<num>" lines will be deleted at the current cursor location.
  362.     Lines from below will be scrolled up.  The blank lines inserted at the
  363.     bottom of the screen (or scrolling region, if one is defined) will be
  364.     colored with the current attribute.
  365.  
  366.     Example:  ESC [ 1 0 Y        delete ten lines
  367.  
  368.     Example:  ESC [ Y            delete one line
  369.  
  370.     Note that this is not an ANSI standard, but something that is in
  371.     BananaCom.  Other COM program folks are welcome to do the same.
  372.  
  373.   ESC [ Z    back tab
  374.  
  375.     Relocate the cursor to the previous tab.  Tabs are located at columns
  376.     1, 8, 16, 24, 32, 40, 48, 56, 64, 72 and 80.  So, if your cursor is
  377.     currently located at column 10 and a "ESC [ Z" is received, the cursor
  378.     will be moved to column 8.
  379.  
  380.   ESC [ a    undefined
  381.  
  382.   ESC [ b    Banana ANSI?
  383.  
  384.     If a terminal uses everything listed in this document, it will send
  385.     back
  386.  
  387.           000
  388.  
  389.     later versions may return  001  or  002  or  003   etc.
  390.  
  391.     Note that this is not an ANSI standard, but something that is in
  392.     BananaCom.  Other COM program folks are welcome to do the same.
  393.  
  394.   ESC [ c    VT100 query response
  395.  
  396.     Some modem services use anal retentive computers that send this and are
  397.     looking for some unique response or they will assume your terminal is
  398.     brain dead.  BananaCom sends back "ESC [ ? 1 ; 2 c" and that seems to
  399.     keep most machines happy.
  400.  
  401.   ESC [ d    undefined
  402.   ESC [ e    undefined
  403.   ESC [ f    undefined
  404.   ESC [ g    undefined
  405.  
  406.   ESC [ h    set options
  407.  
  408.     There are only two options here, both include sending an actual
  409.     question mark as part of the sequence:
  410.  
  411.        ESC [ ? 6 h     certain functions which normally ignore the
  412.                        scrolling region, will now operate relative to the
  413.                        scrolling region.  Note that those functions will
  414.                        again ignore the scrolling region the next time the
  415.                        scrolling region is changed.
  416.  
  417.        ESC [ ? 7 h     Auto word wrap is turned on (it is normally on -
  418.                        this is provided in case you turn it off).
  419.  
  420.   ESC [ i    undefined
  421.   ESC [ j    undefined
  422.   ESC [ k    undefined
  423.  
  424.   ESC [ l    set options
  425.  
  426.     There are only two options here, both include sending an actual
  427.     question mark as part of the sequence.  These compliment the "ESC [ h"
  428.     sequences.  Note that these seqences end with a lowercase L:
  429.  
  430.        ESC [ ? 6 l     Negates "ESC [ ? 6 h".  This is the default.
  431.  
  432.        ESC [ ? 7 l     Auto word wrap is turned off.  Note that the next
  433.                        time you change the scrolling region, word wrap will
  434.                        be turned on again.
  435.  
  436.   ESC [ <num> ; <num> ; ... m    set video attributes
  437.  
  438.     Set the foreground color, background color and blink attributes for
  439.     future text.  Note that each number may overwrite or enhance a previous
  440.     number.  There are four basic attributes:
  441.  
  442.          Foreground color:  8 colors
  443.  
  444.                    Bright:  On or off
  445.  
  446.          Background color:  8 colors
  447.  
  448.                  Blinking:  On or off
  449.                                                  Effects
  450.  
  451.     Possible numbers to pass:                  FC Br BC Bl
  452.  
  453.        0  "normal": gray on black, no blink     x  x  x  x
  454.        1  bright foreground                        x
  455.        2  regular (non-bright) foreground          x
  456.        4  underscore if available               x
  457.        5  Blink on                                       x
  458.        6  Blink on (yup, same as 5)                      x
  459.        7  reverse                               x     x
  460.        8  invisible text (fore=back)            x  x     x
  461.       30  black (+Br=dark gray)                 x
  462.       31  red (+Br=bright red)                  x
  463.       32  green (+Br=bright green)              x
  464.       33  brown (+Br=yellow)                    x
  465.       34  blue (+Br=bright blue)                x
  466.       35  magenta (+Br=bright magenta)          x
  467.       36  cyan (+Br=bright cyan)                x
  468.       37  gray (+Br=white)                      x
  469.       40  black                                       x
  470.       41  red                                         x
  471.       42  green                                       x
  472.       43  brown                                       x
  473.       44  blue                                        x
  474.       45  magenta                                     x
  475.       46  cyan                                        x
  476.       47  gray                                        x
  477.  
  478.     Examples:
  479.  
  480.       ESC [ 0 ; 1 ; 3 3 m        yellow on black with no blink
  481.  
  482.       ESC [ 3 3 m                use same background as before.
  483.                                  no change to blink attribute.
  484.                                  foreground is either brown or yellow
  485.                                  depending on the bright attribute.
  486.  
  487.       ESC [ m                    use "normal" attribute - gray on black,
  488.                                  no blink.
  489.  
  490.   ESC [ 6 n    report current cursor location
  491.  
  492.     If the cursor is located in the lower-right corner of the screen,
  493.     BananaCom will respond "ESC 2 4 ; 8 0 R".  Many modem services will
  494.     send "ESC [ 6 n" before asking a user what their name is.  When the
  495.     response is given, the modem service knows that the calling computer
  496.     supports ANSI terminal emulation.
  497.  
  498.   ESC [ o    undefined
  499.   ESC [ p    undefined
  500.   ESC [ q    undefined
  501.  
  502.   ESC [ <top> ; <bottom> r    set scroll region
  503.  
  504.     Define a region of the screen for scrolling.  This is usually used for
  505.     full screen text editors.  Some information can be stored on some parts
  506.     of the screen that will remain for the entire editing session - such as
  507.     what keys you push to indicate that you are done editing.  The scroll
  508.     region will be where the user types the text of their message.  Some
  509.     commands (escape sequences) always ignore the scrolling region; some
  510.     default to ignoring the scrolling region, but can work relative to the
  511.     scrolling region when the "ESC [ ? 6 h" sequence is sent; some always
  512.     work relative to the scrolling region if one is defined.
  513.  
  514.     Example:  ESC [ 2 ; 2 3 r    leave the first and last lines out of
  515.                                  the scrolling region.
  516.  
  517.     Example:  ESC [ 5 r          the first four lines are left out of the
  518.                                  scrolling region.
  519.  
  520.     Example:  ESC [ r            turn off scrolling region
  521.  
  522.   ESC [ s    save current cursor position
  523.  
  524.     The current cursor position is stored and can be reset with
  525.     "ESC [ u"
  526.  
  527.   ESC [ t    undefined
  528.  
  529.   ESC [ u    restore cursor position from last save
  530.  
  531.     Restores the cursor position that was stored with "ESC [ s"
  532.  
  533.   ESC [ v    undefined
  534.   ESC [ w    undefined
  535.   ESC [ x    undefined
  536.   ESC [ y    undefined
  537.   ESC [ z    undefined
  538.  
  539. The information in this document is for programmers writing all sorts of
  540. communications software - whether BBS's, door programs, or terminal
  541. emulation programs.  If you use this, I hope you mention "Banana ANSI" in
  542. your documentation.
  543.